//
//  ViewController.swift
//  XJSqlite3Tool
//
//  Created by 李胜兵 on 2017/6/10.
//  Copyright © 2017年 善林(中国)金融信息服务有限公司. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let model = XJModel()
        model.name0000 = "李胜兵"
        model.age2 = 77
        model.id = 78
        model.isValid = true
        model.score = 98.05
        model.arr = ["2","3","4","5"]
        let image = UIImage(named: "login_select")!
        let data = UIImagePNGRepresentation(image)
        
        print("data=====\(data)")
        model.data = data ?? Data()
        
        // 保存模型
        _ = XJSqlite3ModelTool.saveOrupdateModel(obj: model, uid: "li")
        
        // 更新模型
        //_ = XJSqlite3ModelTool.isTableRequiredUpdata(cls: XJModel.self, uid: "li")
        
//        // 查询模型
//        let result = XJSqlite3ModelTool.queryAllModelsWithSql(cls: XJModel.self, uid: "li", sql: "select * from XJModel")
//        let models = result as! [XJModel]
//        for model in models {
//            print(model.nameqqqq,model.score,model.arr,model.dict,model.data)
//        }
    }

}











extension ViewController {
//    fileprivate func test() {
//        
//        //let sql = "create table if not exists t_stu(id integer primary key autoincrement, name text not null, age integer, score real, image blob)"
//        //let sql = "CREATE TABLE IF NOT EXISTS t_student(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name TEXT, score REAL)"
//        let sql = "insert into XJModel(name,age) values('iOS','2018')"
//        let result = XJSqlite3Tool.share.xj_deal(sql: sql, uid: "lishengbing")
//        print("result增删改返回结果=\(result)")
//    }
//    
//    fileprivate func test1() {
//        let sql = "select * from t_stu where age = 2018 "
//        //let sql = "insert into t_stu(name,age,score) values('iOS开发','2017','99')"
//        let result = XJSqlite3Tool.share.xj_querySql(sql: sql, uid: "lisi")
//        
//        print("result查询语句返回结果=\(result)")
//    }
}

